/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cxhd.lis.service;

import com.cxhd.lis.util.DateUtil;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Db;
import java.util.List;
import java.util.Map;

/**
 *
 * @author 52461
 */
public class ZkStandardService {

    public boolean save(List<Map<String, String>> list,Controller ctrl) {

        if (list != null && !list.isEmpty()) {

            try {
                for (Map<String, String> map : list) {
                    save(map,ctrl);
                }
            } catch (Exception e) {
                e.printStackTrace();
                return false;
            }
        }
        return true;
    }

    public void save(Map<String, String> map,Controller ctrl) {

        String sql = "replace into zk_standard(ZK_REAGENT_PK,BATCH_NUMBER,STANDARD_VALUE,SD,CV,ZK_OBJECT_PK,DEVICEID,TESTID,UPDAE_DATE) values("
                + "?,?,?,?,?,?,?,?,?)";
                
        Db.update(sql,ctrl.getPara("ZK_REAGENT_PK"), ctrl.getPara("BATCH_NUMBER"),map.get("STANDARD_VALUE"),map.get("SD"), map.get("CV"),map.get("ZK_OBJECT_PK"), ctrl.getPara("device"), map.get("TESTID"),DateUtil.getDateEN());

    }
}
